package com.bawei.module_inspection.ui

import com.bawei.module_inspection.http.InspectionApi
import com.bawei.module_inspection.http.InspectionNetModel
import com.bawei.module_inspection.model.PatrolModelItem
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.flow.flowOn
import javax.inject.Inject

class InspectionRepository @Inject constructor() {

    @Inject
    @InspectionNetModel.CommonMainApi
    lateinit var inspectionApi: InspectionApi

    fun getInspection() = flow {
        emit(inspectionApi.getPatrol())
    }.flowOn(Dispatchers.IO)

    fun postInspection(body: PatrolModelItem) = flow {
        emit(inspectionApi.postPatrol(body))
    }.flowOn(Dispatchers.IO)

    fun getInspectionDetail(id: Int) = flow {
        emit(inspectionApi.getInspectionDetail(id))
    }.flowOn(Dispatchers.IO)

}